﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.MonoRail.ViewComponents;
using Castle.MonoRail.Framework;
using StateTheaterDataModel;
using System.Web.Security;

namespace StateTheater.Component
{
    public class MemberInfoComponent : ViewComponentEx
    {
        [ViewComponentParam(Default = "default")]
        public string View { get; set; }

        public StateTheaterDataContext Db { get; set; }

        public override void Render()
        {
            base.Render();
            var user = Membership.GetUser();
            if (user == null)
            {
                CancelView();
                return;
            }

            PropertyBag["member"] =
                (from m in Db.FORUM_MEMBERs
                where m.M_NAME  == user.UserName
                select m).First();
                RenderView(View);
        }
    }
}
